import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App) 
  // render:function(createElement){
  //   return createElement("h2",{class:'box'},['fsdrftwer'])
  // }
})
//tempkate-ast-render-vdom
router.beforeEach((to,from,next)=>{
  window.document.title=to.meta.title;
 if(to.meta.requireAuth == true){  //需要登录权限进入的路由
   if(!localStorage.getItem('token')){  //取不到登录信息
      return next({name:'login'})
   }else{  //取得到登录信息，进行下一步
     return next();
   }
 }else{  //不需要登录权限
   return next();
 }
})
